<template>
    <div>
        <div class="background-f5 position-r" :style="{minHeight:bodyHeight + 'px'}">
            <van-row class="editor-box-tit background-fff clearfix">
                <van-col span="8">
                    <img class="center-jt" src="../../assets/image/center/icon_return.png" alt="" @click="$router.push('centerAll')">
                </van-col>
                <van-col span="8" class="text-align-c color-3 font-3 top-title">
                    设置
                </van-col>
                <van-col span="8" class="text-align-r color-3 font-2">
                    <span class="wancheng"></span>
                </van-col>
            </van-row>
            <div class="ziliao1 clearfix background-fff">
                <ul class="clearfix">
                    <router-link tag="li" :to="{ name: 'account',query:{phone:phone,bindWx:bindWx}}">
                        <label class="fl">账号绑定</label>
                        <van-icon class="fr" name="arrow" />
                    </router-link>
                    <router-link tag="li" :to="{ name: 'alerts'}">
                        <label class="fl">消息通知</label>
                        <van-icon class="fr" name="arrow" />
                    </router-link>
                    <router-link tag="li" :to="{ name: 'privacy'}">
                        <label class="fl">隐私设置</label>
                        <van-icon class="fr" name="arrow" />
                    </router-link>
                    <li @click="tiaozhuan()">
                        <label class="fl">身份认证</label>
                        <van-icon class="fr" name="arrow" />
                        <span class="fr color-default" v-if="status=='0'">未认证</span>
                        <span class="fr color-default" v-else-if="status=='1'">认证通过</span>
                        <span class="fr color-default" v-else-if="status=='2'">认证审核中</span>
                        <span class="fr color-default" v-else-if="status=='3'">认证审核拒绝</span>
                    </li>
                    <router-link tag="li"  :to="{ name: 'help'}">
                        <label class="fl">帮助</label>
                        <van-icon class="fr" name="arrow" />
                    </router-link>
                </ul>
            </div>
            <p class="phone clearfix font-2 color-9 text-align-c">
                <span>客服电话：400-6562-8888</span>
                <span>工作日 09:00-18:00</span>
            </p>
            <span class="loginOut" @click="loginOut()">退出当前账号</span>
        </div>
    </div>
</template>
<script>
import account from '@/components/settingChild/account'
import alerts from '@/components/settingChild/alerts'
import privacy from '@/components/settingChild/privacy'
import { Toast } from 'vant';
import { Dialog } from 'vant';
import apiHttp from '../../api/index'
export default {
    data(){
        return{
            bodyHeight:'',
            isAccount:false,
            isAlert:false,
            isPrivacy:false,
            phone:this.$route.query.phone,
            bindWx:this.$route.query.bindWx,
            status:''
        }
    },
    components:{
        account,
        alerts,
        privacy
    },
    mounted(){
        this.getUserIdentityAuth();
        let orderHight = document.body.clientHeight
        this.bodyHeight = orderHight
    },
    methods:{

        getUserIdentityAuth(){
            let that = this;
            apiHttp.apiSetting.getUserIdentityAuth('','',resp=>{
                if(resp.code==200){
                    that.status = resp.data.status;
                }

            });
        },
        //跳转
        tiaozhuan(){
            let that = this;
            if(that.status=='0'){
                this.$router.push({
                    name:'identity'
                });
            }else if(that.status=='3'){
                this.$router.push({
                    name:'identity'
                });
            }else if(that.status=='1'){
                Dialog.alert({
                    message: '您已身份认证通过，如需修改请联系客服。'
                }).then(() => {
                    // on close
                });
            }else if(that.status=='2'){
                Dialog.alert({
                    message: '认证审核中！'
                }).then(() => {
                    // on close
                });
            }

        },
        loginOut(){
            apiHttp.apiCenter.logout('',resp=>{
                if(resp.code == 200){
                    Toast('退出成功')
                    localStorage.removeItem('token')
                    this.$store.state.token=''
                    this.$router.push({
                        name:'login'
                    })
                }
            })
        }
    }
}
</script>

<style scoped>
.ziliao1 li {
    height: 1.8rem;
    line-height: 1.8rem;
    color: #333;
    font-size: .6rem;
    border-bottom: #eeeeee solid .02rem;
    padding: 0 .6rem;
}
.van-icon-arrow{
    margin-top: .6rem;
    margin-left: .4rem;
}
.van-tabbar{
    height: 1rem;
}
.van-tabbar span{
    width: 100%;
    height: 1rem;
    display: block;
    text-align: center;
    font-size: .6rem;
}
.phone{
    width: 100%;
    position: absolute;
    left: 0;
    bottom: 2.6rem;
}
.phone span{
    display: block;
    line-height: .8rem;
}
.van-popup{
    width: 100%;
    height: 100%;
}
.loginOut{
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 1.8rem;
    line-height: 1.8rem;
    background-color: #fff;
    text-align: center;
    font-size: .6rem;
    z-index: 100;
}
</style>

